#ifndef AVALON_BINARYDESERIALIZER_HPP
#define AVALON_BINARYDESERIALIZER_HPP
#include "Avalon/Serialization/Deserializer.hpp"

namespace Avalon {
namespace Serialization {

  /*! \class BinaryDeserializer
   *  \brief Implements the DataShuttle using binary deserialization.
   *  \author Kamal Mansouri <kranar@hotmail.com>
   */
  class BinaryDeserializer : public Deserializer {
    public:

      //! Constructs a BinaryDeserializer.
      BinaryDeserializer();

      virtual ~BinaryDeserializer();

      virtual void SetDataSource(const void* source, int size);

      virtual void Shuttle(const char* name, bool& value);

      virtual void Shuttle(const char* name, char& value);

      virtual void Shuttle(const char* name, short& value);

      virtual void Shuttle(const char* name, int& value);

      virtual void Shuttle(const char* name, long& value);

      virtual void Shuttle(const char* name, long long& value);

      virtual void Shuttle(const char* name, float& value);

      virtual void Shuttle(const char* name, double& value);

      virtual void Shuttle(const char* name, std::string& value);

      virtual void Shuttle(const char* name, IO::Buffer& data);

      using Deserializer::Shuttle;

    private:
      const void* m_source;
      int m_remainingSize;
      const char* m_readIterator;

      template<typename T> void DeserializePrimitive(T& value);
  };
}
}

#endif // AVALON_BINARYDESERIALIZER_HPP
